unit uDB;

interface

uses Uni, DB;

type
   TDB = class
      private
         FConexao: TUniConnection;

      public
         constructor Create(pConnection: TUniConnection); reintroduce;

         procedure StartTransaction;
         procedure CommitTransaction;
         procedure RollbackTransaction;
   end;

var
   clDB: TDB;

implementation

{ TDB }

procedure TDB.CommitTransaction;
begin
   if FConexao.InTransaction then
      FConexao.Commit;
end;

constructor TDB.Create(pConnection: TUniConnection);
begin
   FConexao := pConnection;
end;

procedure TDB.RollbackTransaction;
begin
   if FConexao.InTransaction then
      FConexao.Rollback;
end;

procedure TDB.StartTransaction;
begin
   if not FConexao.InTransaction then
      FConexao.StartTransaction;
end;

end.
